// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Snapshot;

public sealed partial class S3RepositorySettings
{
	[JsonInclude, JsonPropertyName("base_path")]
	public string? BasePath { get; set; }
	[JsonInclude, JsonPropertyName("bucket")]
	public string Bucket { get; set; }
	[JsonInclude, JsonPropertyName("buffer_size")]
	public Elastic.Clients.Elasticsearch.ByteSize? BufferSize { get; set; }
	[JsonInclude, JsonPropertyName("canned_acl")]
	public string? CannedAcl { get; set; }
	[JsonInclude, JsonPropertyName("chunk_size")]
	public Elastic.Clients.Elasticsearch.ByteSize? ChunkSize { get; set; }
	[JsonInclude, JsonPropertyName("client")]
	public string? Client { get; set; }
	[JsonInclude, JsonPropertyName("compress")]
	public bool? Compress { get; set; }
	[JsonInclude, JsonPropertyName("max_restore_bytes_per_sec")]
	public Elastic.Clients.Elasticsearch.ByteSize? MaxRestoreBytesPerSec { get; set; }
	[JsonInclude, JsonPropertyName("max_snapshot_bytes_per_sec")]
	public Elastic.Clients.Elasticsearch.ByteSize? MaxSnapshotBytesPerSec { get; set; }
	[JsonInclude, JsonPropertyName("readonly")]
	public bool? Readonly { get; set; }
	[JsonInclude, JsonPropertyName("server_side_encryption")]
	public bool? ServerSideEncryption { get; set; }
	[JsonInclude, JsonPropertyName("storage_class")]
	public string? StorageClass { get; set; }
}

public sealed partial class S3RepositorySettingsDescriptor : SerializableDescriptor<S3RepositorySettingsDescriptor>
{
	internal S3RepositorySettingsDescriptor(Action<S3RepositorySettingsDescriptor> configure) => configure.Invoke(this);

	public S3RepositorySettingsDescriptor() : base()
	{
	}

	private string? BasePathValue { get; set; }
	private string BucketValue { get; set; }
	private Elastic.Clients.Elasticsearch.ByteSize? BufferSizeValue { get; set; }
	private string? CannedAclValue { get; set; }
	private Elastic.Clients.Elasticsearch.ByteSize? ChunkSizeValue { get; set; }
	private string? ClientValue { get; set; }
	private bool? CompressValue { get; set; }
	private Elastic.Clients.Elasticsearch.ByteSize? MaxRestoreBytesPerSecValue { get; set; }
	private Elastic.Clients.Elasticsearch.ByteSize? MaxSnapshotBytesPerSecValue { get; set; }
	private bool? ReadonlyValue { get; set; }
	private bool? ServerSideEncryptionValue { get; set; }
	private string? StorageClassValue { get; set; }

	public S3RepositorySettingsDescriptor BasePath(string? basePath)
	{
		BasePathValue = basePath;
		return Self;
	}

	public S3RepositorySettingsDescriptor Bucket(string bucket)
	{
		BucketValue = bucket;
		return Self;
	}

	public S3RepositorySettingsDescriptor BufferSize(Elastic.Clients.Elasticsearch.ByteSize? bufferSize)
	{
		BufferSizeValue = bufferSize;
		return Self;
	}

	public S3RepositorySettingsDescriptor CannedAcl(string? cannedAcl)
	{
		CannedAclValue = cannedAcl;
		return Self;
	}

	public S3RepositorySettingsDescriptor ChunkSize(Elastic.Clients.Elasticsearch.ByteSize? chunkSize)
	{
		ChunkSizeValue = chunkSize;
		return Self;
	}

	public S3RepositorySettingsDescriptor Client(string? client)
	{
		ClientValue = client;
		return Self;
	}

	public S3RepositorySettingsDescriptor Compress(bool? compress = true)
	{
		CompressValue = compress;
		return Self;
	}

	public S3RepositorySettingsDescriptor MaxRestoreBytesPerSec(Elastic.Clients.Elasticsearch.ByteSize? maxRestoreBytesPerSec)
	{
		MaxRestoreBytesPerSecValue = maxRestoreBytesPerSec;
		return Self;
	}

	public S3RepositorySettingsDescriptor MaxSnapshotBytesPerSec(Elastic.Clients.Elasticsearch.ByteSize? maxSnapshotBytesPerSec)
	{
		MaxSnapshotBytesPerSecValue = maxSnapshotBytesPerSec;
		return Self;
	}

	public S3RepositorySettingsDescriptor Readonly(bool? value = true)
	{
		ReadonlyValue = value;
		return Self;
	}

	public S3RepositorySettingsDescriptor ServerSideEncryption(bool? serverSideEncryption = true)
	{
		ServerSideEncryptionValue = serverSideEncryption;
		return Self;
	}

	public S3RepositorySettingsDescriptor StorageClass(string? storageClass)
	{
		StorageClassValue = storageClass;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(BasePathValue))
		{
			writer.WritePropertyName("base_path");
			writer.WriteStringValue(BasePathValue);
		}

		writer.WritePropertyName("bucket");
		writer.WriteStringValue(BucketValue);
		if (BufferSizeValue is not null)
		{
			writer.WritePropertyName("buffer_size");
			JsonSerializer.Serialize(writer, BufferSizeValue, options);
		}

		if (!string.IsNullOrEmpty(CannedAclValue))
		{
			writer.WritePropertyName("canned_acl");
			writer.WriteStringValue(CannedAclValue);
		}

		if (ChunkSizeValue is not null)
		{
			writer.WritePropertyName("chunk_size");
			JsonSerializer.Serialize(writer, ChunkSizeValue, options);
		}

		if (!string.IsNullOrEmpty(ClientValue))
		{
			writer.WritePropertyName("client");
			writer.WriteStringValue(ClientValue);
		}

		if (CompressValue.HasValue)
		{
			writer.WritePropertyName("compress");
			writer.WriteBooleanValue(CompressValue.Value);
		}

		if (MaxRestoreBytesPerSecValue is not null)
		{
			writer.WritePropertyName("max_restore_bytes_per_sec");
			JsonSerializer.Serialize(writer, MaxRestoreBytesPerSecValue, options);
		}

		if (MaxSnapshotBytesPerSecValue is not null)
		{
			writer.WritePropertyName("max_snapshot_bytes_per_sec");
			JsonSerializer.Serialize(writer, MaxSnapshotBytesPerSecValue, options);
		}

		if (ReadonlyValue.HasValue)
		{
			writer.WritePropertyName("readonly");
			writer.WriteBooleanValue(ReadonlyValue.Value);
		}

		if (ServerSideEncryptionValue.HasValue)
		{
			writer.WritePropertyName("server_side_encryption");
			writer.WriteBooleanValue(ServerSideEncryptionValue.Value);
		}

		if (!string.IsNullOrEmpty(StorageClassValue))
		{
			writer.WritePropertyName("storage_class");
			writer.WriteStringValue(StorageClassValue);
		}

		writer.WriteEndObject();
	}
}